{template '_header'}

<div class="page-heading"> 
    <h2>会员管理</h2> </div>

<form action="./index.php" method="get" class="form-horizontal form-search" role="form">
    <input type="hidden" name="c" value="site" />
    <input type="hidden" name="a" value="entry" />
    <input type="hidden" name="m" value="ewei_shopv2" />
    <input type="hidden" name="do" value="web" />
    <input type="hidden" name="r" value="sns.member" />
    <div class="page-toolbar row m-b-sm m-t-sm">
        <div class="col-sm-4">

            <div class="input-group-btn">
                <button class="btn btn-default btn-sm"  type="button" data-toggle='refresh'><i class='fa fa-refresh'></i></button>
                {ifp 'sns.member.edit'}
	                <button class="btn btn-default btn-sm" type="button" data-toggle='batch' data-href="{php echo webUrl('sns/member/setblack',array('isblack'=>0))}"><i class='fa fa-circle'></i> 取消黑名单</button>
	                <button class="btn btn-default btn-sm" type="button" data-toggle='batch'  data-href="{php echo webUrl('sns/member/setblack',array('isblack'=>1))}"><i class='fa fa-circle-o'></i> 设置黑名单</button>
                {/if}

                {ifp 'sns.member.delete'}
                <button class="btn btn-default btn-sm" type="button" data-toggle='batch' data-href="{php echo webUrl('sns/member/delete')}"><i class='fa fa-remove'></i> 删除</button>
                {/if}
              
            </div>
        </div>	


        <div class="col-sm-7 pull-right">
            <select name="level" class='form-control input-sm select-sm'>
                <option value="" {if $_GPC['level'] == ''} selected{/if}>等级</option>
                <option value="" {if $_GPC['level'] == '0'} selected{/if}>{php echo empty($this->set['levelname'])?'社区粉丝':$this->set['levelname']}</option>
                {loop $levels $level}
                <option value="{$level['id']}" {if $_GPC['level']== $level['id']} selected{/if}>{$level['levelname']}</option>
                {/loop}
            </select>
            <select name="isblack" class='form-control input-sm select-sm'>
                <option value="" {if $_GPC['isblack'] == ''} selected{/if}>状态</option>
                <option value="1" {if $_GPC['isblack']== '1'} selected{/if}>黑名单</option>
                <option value="0" {if $_GPC['isblack'] == '0'} selected{/if}>正常</option>
            </select>	
            <div class="input-group">				 
                <input type="text" class="input-sm form-control" name='keyword' value="{$_GPC['keyword']}" placeholder="请输入关键词"> <span class="input-group-btn">
                    		
                    <button class="btn btn-sm btn-primary" type="submit"> 搜索</button> </span>
            </div>

        </div>
    </div>
</form>

<form action="" method="post">
    {if count($list)>0}

    <table class="table table-responsive table-hover" >
        <thead class="navbar-inner">
            <tr>
                <th style="width:25px;"><input type='checkbox' /></th>
                <th style="width:100px;">粉丝</th>
                <th style="width:120px;">会员信息</th>
                <th style="width:100px;">等级</th>
                <th style="width:100px;">注册时间</th>
                <th style="width:100px;">社区信息</th>
                <th style="width:100px;">关注/黑名单</th>
                <th style="width:70px;">操作</th>
            </tr>
        </thead>
        <tbody>
        {loop $list $row}
        <tr rel="pop" data-title="ID: {$row['id']} " data-content="推荐人 <br/>
                {if empty($row['agentid'])}
				  {if $row['isagent']==1}
				      <label class='label label-primary'>总店</label>
				      {else}
				       <label class='label label-default'>暂无</label>
				      {/if}
				{else}

                    	{if !empty($row['agentavatar'])}
                         <img src='{$row['agentavatar']}' style='width:20px;height:20px;padding1px;border:1px solid #ccc' />
                       {/if}
                       [{$row['agentid']}]{if empty($row['agentnickname'])}未更新{else}{$row['agentnickname']}{/if}
					   {/if}">


            <td style="position: relative; ">

                <input type='checkbox'   value="{$row['sns_id']}"/></td>
            <td  >
                <div  >
                    {if !empty($row['avatar'])}
                    <img src='{$row['avatar']}' style='width:30px;height:30px;padding1px;border:1px solid #ccc' />
                    {/if}
                    {if empty($row['nickname'])}未更新{else}{$row['nickname']}{/if}
                </div>
            </td>
            <td>{$row['realname']}<br/>{$row['mobile']}</td>

            <td><span class="label label-default" style="background:{$row['level']['bg']};color:{$row['level']['color']}">{$row['level']['levelname']}</span></td>
            <td>{php echo date("Y-m-d",$row['createtime'])}<br/>{php echo date("H:i:s",$row['createtime'])}</td>
            <td>
            <label class="label label-warning">积分: {php echo intval($row['sns_credit'])}</label><br/>
                <label class="label label-success">话题: {php echo intval($row['sns_postcount'])}</label><br/>
                <label class="label label-primary">评论: {php echo intval($row['sns_replycount'])}</label>
            </td>
            <td>

                {if empty($row['followed'])}
                {if empty($row['uid'])}
                <label class='label label-default'>未关注</label>
                {else}
                <label class='label label-warning'>取消关注{$row['fanid']}</label>
                {/if}
                {else}
                <label class='label label-success'>已关注</label>
                {/if}

                <br/><label class='label {if $row['isblack']==1}label-error{else}label-primary{/if}'
                {ifp 'sns.member.edit'}
                data-toggle='ajaxSwitch'
                data-switch-value='{$row['isblack']}'
                data-switch-value0='0|正常|label label-primary|{php echo webUrl('sns/member/setblack',array('isblack'=>1,'id'=>$row['sns_id']))}'
                data-switch-value1='1|黑名单|label label-error|{php echo webUrl('sns/member/setblack',array('isblack'=>0,'id'=>$row['sns_id']))}'
                {/if}
                >
                {if $row['isblack']==1}黑名单{else}正常{/if}</label>

            </td>


            <td  style="overflow:visible;">

                <div class="btn-group btn-group-sm" >
                    <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false" href="javascript:;">操作 <span class="caret"></span></a>
                    <ul class="dropdown-menu dropdown-menu-left" role="menu" style='z-index: 9999'>

                        {ifp 'member.list.detail'}
                        <li><a href="{php echo webUrl('member/list/detail',array('id' => $row['id']));}" title="会员详情" target="_blank"><i class='fa fa-edit'></i> 会员详情</a></li>
                        {/if}

                        {ifp 'sns.posts'}
                        <li><a href="{php echo webUrl('sns/posts',array('uid' => $row['id']));}" title="查看话题"><i class='fa fa-comment'></i> 查看话题</a></li>
                        {/if}
                        {ifp 'sns.member.delete'}<li><a  data-toggle='ajaxRemove'  href="{php echo webUrl('sns/member/delete',array('id' => $row['sns_id']));}" title='删除会员' data-confirm="此会员话题及评论会全部删除，确定要删除该会员吗？"><i class='fa fa-remove'></i> 删除会员</a></li>{/if}
                    </ul>
                </div>


            </td>
        </tr>
        {/loop}
            </tbody>
        </table>
        {$pager}


    <script language="javascript">
        {if $opencommission}
        require(['bootstrap'],function(){
            $("[rel=pop]").popover({
                trigger:'manual',
                placement : 'left',
                title : $(this).data('title'),
                html: 'true',
                content : $(this).data('content'),
                animation: false
            }).on("mouseenter", function () {
                var _this = this;
                $(this).popover("show");
                $(this).siblings(".popover").on("mouseleave", function () {
                    $(_this).popover('hide');
                });
            }).on("mouseleave", function () {
                var _this = this;
                setTimeout(function () {
                    if (!$(".popover:hover").length) {
                        $(_this).popover("hide")
                    }
                }, 100);
            });


        });
        {/if}

    </script>

        {else}
        <div class='panel panel-default'>
            <div class='panel-body' style='text-align: center;padding:30px;'>
                暂时没有任何会员!
            </div>
        </div>
        {/if}

    </form>


    {template '_footer'}